from postgresql import Postgresql


def read_file_lines(file_path):
    lines_list = []
    with open(file_path, 'r') as file:
        for line in file:
            lines_list.append(line.strip())
    return lines_list

lines_list = read_file_lines('./execution.log')

# 创建Postgresql实例并传入连接参数
postgresql = Postgresql(host="10.10.49.191", database="www", user="postgres", password="123456")

# 创建连接和游标对象
postgresql.create_connection()

# 示例插入数据
for lines_list_one in lines_list:
  data = {"stock_code": f"{lines_list_one}"}
  result = postgresql.execute_insert("company_info", data)
  postgresql.execute_commit()

# 关闭连接
postgresql.quit_connection()

print(result)